package edu.sctu.boot.admin.generator.utils;

import java.io.StringWriter;

public class StringUtils {

    // "name" -> "Name" 首字母大写
    public static String capitalFirst(String name) {
        name = name.substring(0, 1).toUpperCase() + name.substring(1);
        return name;
    }

    // "my_real_name" -> myRealName
    public static final String convert(String raw) {
        if (!raw.contains("_"))
            return raw;

        String[] tokens = raw.split("_");

        StringWriter sw = new StringWriter();

        //第一个单词
        sw.write(tokens[0]);

        for (int i = 1; i < tokens.length; i++) {
            sw.write(StringUtils.capitalFirst(tokens[i]));
        }

        return sw.toString();
    }
}
